<?php  if (!defined('BASEPATH')) exit('No direct script access allowed');

require_once APPPATH . 'controllers/admin.php';

/**
 * Контроллер изменения кода ссылок
 *
 * @package CoreFramework
 * @version 1.0
 * @author Gennadiy Kozlenko
 */
class Admin_Edit_Links_Code extends Admin {
   
   /**
    * Конструктор класса
    *
    * @access public
    * @return Admin_Edit_Links_Code
    */
   function Admin_Edit_Links_Code() {
      parent::Admin();
      $this->set_menu(5, 1);
   } // end Admin_Edit_Links_Code
   
   /**
    * Метод по умолчанию
    *
    * @access public
    */
   function index() {
      $data = array();
      $this->load->helper('file');
      $content = '';
      if (false !== $this->input->post('edit')) {
         
         $content = $this->input->post('content');
         // Сохраняем код
         if (write_file(APPPATH . 'misc/links_code.php', $content)) {
            $this->set_message($this->lang->line('edit_links_code_succ'), 'info', true);
            $this->redirect($this->get_controller());
         }
         $this->set_message($this->lang->line('edit_links_code_error'), 'error');
      } else {
         $content = read_file(APPPATH . 'misc/links_code.php');
      }
      // Забиваем в дату поля
      $content = str_replace(array('{%', '%}'), array('{-%', '%-}'), $content);
      $data['content'] = htmlspecialchars($content);
      // Выводим
      $this->set_content($this->parser->parse('admin/edit_links_code.html', $data, true));
      $this->display();
   } // end index
   
}
